package com;

import com.google.gson.JsonObject;
import com.google.gson.JsonParser;

import javax.servlet.http.HttpServletRequest;
import java.io.BufferedReader;
import java.io.IOException;

public class JsonConvert{
   public static JsonObject JsonChange(HttpServletRequest req){
       StringBuilder sb = new StringBuilder();
       try (BufferedReader reader = req.getReader();){

           char[]buff = new char[1024];
           int len;
           while((len = reader.read(buff)) != -1) {
               sb.append(buff,0, len);
           }
       }catch (IOException e) {
           e.printStackTrace();
       }

       JsonParser jp = new JsonParser();
       return jp.parse(sb.toString()).getAsJsonObject();
    }
}